<%@ page import="bean.Food" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="impl.UserDaoImpl" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: zhang
  Date: 2021/3/31
  Time: 10:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>主页</title>
</head>
<body>
<div>
    <form action="main" method="get" name="foodList">
    <table border="1px" width="100%">
        <tr class="aa">
            <td class="bb">名称</td>
            <td class="bb">价格</td>
            <td class="bb">生产地</td>
            <td class="bb">生产日期</td>
        </tr>
        <%
            List<Food> foodList = new ArrayList<>();
            int i = 0;
            UserDaoImpl userDao = new UserDaoImpl();
            foodList = userDao.getFood();
            pageContext.setAttribute("foodList",foodList);
            while (i<foodList.size()){
        %>

            <tr class="aa" height="200px">
                <td class="bb">&nbsp;&nbsp;&nbsp;&nbsp;<input class="cc" type="text" name="foodname" value="${foodList.get(i).foodname}"/></td>
                <td class="bb">&nbsp;&nbsp;&nbsp;&nbsp;<input class="cc" type="text" name="price" value="${foodList.get(i).price}"/></td>
                <td class="bb">&nbsp;&nbsp;&nbsp;&nbsp;<input class="cc" type="text" name="address" value="${foodList.get(i).address}"/></td>
                <td class="bb">&nbsp;&nbsp;&nbsp;&nbsp;<input class="cc" type="text" name="data" value="${foodList.get(i).data}"/></td>
            </tr>
        <%
                i++;
            }
        %>

    </table>
    </form>
</div>
<button onclick=window.open("${pageContext.request.contextPath}/AddFood.jsp")>添加</button>

<div id="b">
</div>
</body>
</html>
